<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Constrained template macros - Boost.Outcome documentation</title>
<link rel="stylesheet" href="../../css/boost.css" type="text/css">
<meta name="generator" content="Hugo 0.52 with Boostdoc theme">
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>

<link rel="icon" href="../../images/favicon.ico" type="image/ico"/>
<body><div class="spirit-nav">
<a accesskey="p" href="../../reference/macros.html"><img src="../../images/prev.png" alt="Prev"></a>
    <a accesskey="u" href="../../reference/macros.html"><img src="../../images/up.png" alt="Up"></a>
    <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/macros/version.html"><img src="../../images/next.png" alt="Next"></a></div><div id="content">
  <div class="titlepage"><div><div><h1 style="clear: both">Constrained template macros</h1></div></div></div>
  <p><em>Overridable</em>: All of the following macros are overridable, define before inclusion.</p>

<p><em>Header</em>: <code>&lt;boost/outcome/config.hpp&gt;</code></p>

<p>These macros expand into either the syntax for directly specifying constrained templates in C++ 20, or into a SFINAE based emulation for earlier C++ versions. Form of usage looks as follows:</p>
<div class="highlight"><pre class="chroma"><code class="language-c++" data-lang="c++"><span class="n">BOOST_OUTCOME_TEMPLATE</span><span class="p">(</span><span class="k">class</span><span class="err"> </span><span class="nc">ErrorCondEnum</span><span class="p">)</span>
  <span class="n">BOOST_OUTCOME_TREQUIRES</span><span class="p">(</span>
    <span class="c1">// If this is a valid expression
</span><span class="c1"></span>    <span class="n">BOOST_OUTCOME_TEXPR</span><span class="p">(</span><span class="n">error_type</span><span class="p">(</span><span class="n">make_error_code</span><span class="p">(</span><span class="n">ErrorCondEnum</span><span class="p">()))),</span>
    <span class="c1">// If this predicate is true
</span><span class="c1"></span>    <span class="n">BOOST_OUTCOME_TPRED</span><span class="p">(</span><span class="n">predicate</span><span class="o">::</span><span class="k">template</span> <span class="n">enable_error_condition_converting_constructor</span><span class="o">&lt;</span><span class="n">ErrorCondEnum</span><span class="o">&gt;</span><span class="p">)</span>
    <span class="c1">// Any additional requirements follow here ...
</span><span class="c1"></span>  <span class="p">)</span>
  <span class="k">constexpr</span> <span class="n">basic_result</span><span class="p">(</span><span class="n">ErrorCondEnum</span> <span class="o">&amp;&amp;</span><span class="n">t</span><span class="p">,</span> <span class="n">error_condition_converting_constructor_tag</span> <span class="cm">/*unused*/</span> <span class="o">=</span> <span class="p">{});</span>
</code></pre></div>
<p>Be aware that slightly different semantics occur for real C++ 20 constrained templates than for the SFINAE emulation.</p>

<ul>
<li><p><a name="template"></a><code>BOOST_OUTCOME_TEMPLATE(template args ...)</code></p>

<p>Begins a constrained template declaration.</p></li>

<li><p><a name="trequires"></a><code>BOOST_OUTCOME_TREQUIRES(requirements ...)</code></p>

<p>Specifies the requirements for the constrained template to be available for selection by the compiler.</p></li>

<li><p><a name="texpr"></a><code>BOOST_OUTCOME_TEXPR(expression)</code></p>

<p>A requirement that the given expression is valid.</p></li>

<li><p><a name="tpred"></a><code>BOOST_OUTCOME_TPRED(boolean)</code></p>

<p>A requirement that the given constant time expression is true.</p></li>
</ul>


        </div><p><small>Last revised: December 12, 2018 at 22:01:42 UTC</small></p>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../reference/macros.html"><img src="../../images/prev.png" alt="Prev"></a>
    <a accesskey="u" href="../../reference/macros.html"><img src="../../images/up.png" alt="Up"></a>
    <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/macros/version.html"><img src="../../images/next.png" alt="Next"></a></div></body>
</html>
